package com.coding.controller;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import com.coding.config.LiveClientConfig;
import com.coding.dto.RestBean;
import com.coding.pojo.LiveInfo;
import com.coding.service.LiveService;
import com.coding.utils.AliyunOSSUtil;
import com.coding.utils.Create_Live_Url;
import com.coding.utils.LiveUtil;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/live")
@Log
public class LiveController {

    @Autowired
    private LiveService liveService;

    // 创建直播间
    @RequestMapping("/create")
    public RestBean createLiveRoom(@RequestParam("userId") String userId, @RequestParam ("title") String title, @RequestParam(value = "coverImage",required = false)MultipartFile coverImage) {
       return liveService.createLiveRoom(userId, title, coverImage);
    }

    // 获取所有直播间信息
    @RequestMapping("/AllLiveInfo")
     public RestBean<ArrayList<LiveInfo>> getAllLiveInfo() {
        return liveService.getAllLiveInfo();
    }


    //主播停止直播
     @RequestMapping("/stopLive")
     public RestBean<String> stopLive(String roomId) {
        return liveService.stopLive(roomId);
     }

     //获取正在推流的直播流
     @RequestMapping("/getAllLive")
     public RestBean getAllLive() {
        return liveService.getAllLive();

     }

     //管理员封禁直播间

    @RequestMapping("/banLive")
    public RestBean banLive(String streamName, String BannedDuration) {
        return liveService.banStream(streamName, BannedDuration);
    }


}
